home *** CD-ROM | disk | FTP | other *** search
/ Apple Developer Connection Student Program / ADC Tools Sampler CD Disk 3 1999.iso / Cool Demos, SDKs, & Tools / Demos⁄Tools⁄Offers / Alpha ƒ / Tcl / Packages / printerChoices.tcl < prev    next >
Text File  |  1998-04-12  |  2KB  |  82 lines

  1. ## -*-Tcl-*- (install)
  2.  # ###################################################################
  3.  #  Alpha - new Tcl folder configuration
  4.  # 
  5.  #  FILE: "printerChoices.tcl"
  6.  #                                    created: 13/9/97 {2:30:36 pm} 
  7.  #                                last update: 04/12/98 {17:54:26 PM} 
  8.  #  
  9.  # Reorganisation carried out by Vince Darley with much help from Tom 
  10.  # Fetherston, Johan Linde and suggestions from the Alpha-D mailing list.  
  11.  # Alpha is shareware; please register with the author using the register 
  12.  # button in the about box.
  13.  #  
  14.  # Description:
  15.  # 
  16.  # This package converts the basic 'Print…' menu item into a sub-menu
  17.  # from which the user can select a variety of printing methods.
  18.  # This used to be part of standard Alpha, but it seemed a good
  19.  # candidate to split off into a package.
  20.  # ###################################################################
  21.  ##
  22.  
  23. alpha::extension printerChoicesMenu 0.2 {
  24.     menu::buildProc print setupPrintMenu
  25.     menu::replaceWith File "/P<Sprint…" submenu print
  26. }
  27.  
  28. newPref var defaultPrinter "Alpha" global setupPrintMenu \
  29.   {Alpha Kodex Enscriptor {Drop•PS} PrettyC}
  30. lunion varPrefs(Printer) defaultPrinter
  31.  
  32. proc setupPrintMenu {args} {
  33.     global defaultPrinter 
  34.     set m [list {/P<SPrint…} {/P<S<I<OPrint All…} "\(-" \
  35.       Alpha Kodex Enscriptor {Drop•PS} PrettyC]
  36.     Menu -m -n print -p menu::print $m
  37.     
  38.     foreach item $m {
  39.     if {$item == $defaultPrinter} {
  40.         markMenuItem -m print $item on
  41.     } else {
  42.         markMenuItem -m print $item off
  43.     }
  44.     }
  45. }
  46.  
  47. proc menu::print {menu item} {
  48.     global modifiedVars defaultPrinter
  49.     switch -glob $item {
  50.     "Print All"    {    
  51.         if {$defaultPrinter == "Alpha"} {
  52.         printAll
  53.         } else {
  54.         foreach f [winNames -f] {
  55.             printFile $f
  56.         }
  57.         }
  58.     }
  59.     "Print"    {
  60.         printFile [win::Current]
  61.     }
  62.     default {
  63.         set defaultPrinter $item
  64.         lappend modifiedVars defaultPrinter
  65.         setupPrintMenu
  66.     }
  67.     }
  68. }
  69.  
  70. proc printFile {fname} {
  71.     global defaultPrinter
  72.     
  73.     switch -glob $defaultPrinter {
  74.     "Alpha"            {print}
  75.     "Kodex*"        {openAndSendFile KoDX}
  76.     "Enscr*"        {openAndSendFile Ens3}
  77.     "Drop*"            {openAndSendFile {D•PS}}
  78.     "Pret*"            {openAndSendFile niCe}
  79.     }
  80. }
  81.  
  82.